package com.chrray.position.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.chrray.position.domain.dto.DeleteParam;
import com.chrray.position.service.position.FdFeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.chrray.position.domain.vo.FdFeedbackVO;
import com.chrray.position.domain.dto.search.FdFeedbackSearch;
import com.chrray.position.domain.dto.FdFeedbackDTO;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 意见反馈表控制器
 *
 * @author wusiwee
 * @email wusiwee@163.com
 * @since 1.0.1 2024-08-07
 */
@RestController
@RequestMapping("/api/app/feedback")
@Api(tags = "意见反馈表")
@AllArgsConstructor
public class FdFeedbackController {

    private final FdFeedbackService fdFeedbackService;

    @PostMapping("/create")
    @ApiOperation("新增用户反馈")
    public R<Boolean> saveOrUpdate(@RequestBody FdFeedbackDTO body){
        return R.ok(fdFeedbackService.create(body));
    }



    @GetMapping("/pageList")
    @ApiOperation("分页列表")
    @ApiResponses({
        @ApiResponse(code=200, message = "ok", response = FdFeedbackVO.class)
    })
    public R<IPage<FdFeedbackVO>> pageList(@Valid FdFeedbackSearch param){
        return R.ok(fdFeedbackService.pageList(param));
    }

    @GetMapping("/{id}")
    @ApiOperation("查询详情")
    @ApiResponses({
        @ApiResponse(code=200, message = "ok", response = FdFeedbackVO.class)
    })
    public R<FdFeedbackVO> get(@ApiParam(name = "id",value = "主键id",required = true) @PathVariable("id") Long id){
        return R.ok(fdFeedbackService.info(id));
    }



    @DeleteMapping("/remove")
    @ApiOperation("批量删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "idList", value = "主键数组")
    })
    public R<Boolean> delete(@RequestBody DeleteParam param){
        return R.ok(fdFeedbackService.delete(param.getIds()));
    }
}
